package com.ruoyi.washer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.washer.domain.XwWashball;
import com.ruoyi.washer.service.IXwWashballService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 洗衣球Controller
 * 
 * @author hawking
 * @date 2023-12-15
 */
@RestController
@RequestMapping("/washer/washball")
public class XwWashballController extends BaseController
{
    @Autowired
    private IXwWashballService xwWashballService;

    /**
     * 查询洗衣球列表
     */
    @PreAuthorize("@ss.hasPermi('washer:washball:list')")
    @GetMapping("/list")
    public TableDataInfo list(XwWashball xwWashball)
    {
        startPage();
        List<XwWashball> list = xwWashballService.selectXwWashballList(xwWashball);
        return getDataTable(list);
    }

    /**
     * 导出洗衣球列表
     */
    @PreAuthorize("@ss.hasPermi('washer:washball:export')")
    @Log(title = "洗衣球", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XwWashball xwWashball)
    {
        List<XwWashball> list = xwWashballService.selectXwWashballList(xwWashball);
        ExcelUtil<XwWashball> util = new ExcelUtil<XwWashball>(XwWashball.class);
        util.exportExcel(response, list, "洗衣球数据");
    }

    /**
     * 获取洗衣球详细信息
     */
    @PreAuthorize("@ss.hasPermi('washer:washball:query')")
    @GetMapping(value = "/{washballId}")
    public AjaxResult getInfo(@PathVariable("washballId") Long washballId)
    {
        return success(xwWashballService.selectXwWashballByWashballId(washballId));
    }

    /**
     * 新增洗衣球
     */
    @PreAuthorize("@ss.hasPermi('washer:washball:add')")
    @Log(title = "洗衣球", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XwWashball xwWashball)
    {
        return toAjax(xwWashballService.insertXwWashball(xwWashball));
    }

    /**
     * 修改洗衣球
     */
    @PreAuthorize("@ss.hasPermi('washer:washball:edit')")
    @Log(title = "洗衣球", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XwWashball xwWashball)
    {
        return toAjax(xwWashballService.updateXwWashball(xwWashball));
    }

    /**
     * 删除洗衣球
     */
    @PreAuthorize("@ss.hasPermi('washer:washball:remove')")
    @Log(title = "洗衣球", businessType = BusinessType.DELETE)
	@DeleteMapping("/{washballIds}")
    public AjaxResult remove(@PathVariable Long[] washballIds)
    {
        return toAjax(xwWashballService.deleteXwWashballByWashballIds(washballIds));
    }
}
